{% extends 'base.html' %}
{% block content %}
    <script type="text/javascript" language="javascript">
        function MakeTaskDoneNot(id) {
            $.ajax({
                type: "POST",
                url: "/api/task/done",
                data: "tid=" + id + "&tids=false"
            }).done(function() {
                        $("#task_link").attr({onclick: "MakeTaskDone(" + id + "); return false;"});
                        $("#task_link").text("Сделано!");
                    });
        }

        function MakeTaskDone(id) {
            $.ajax({
                type: "POST",
                url: "/api/task/done",
                data: "tid=" + id + "&tids=true"
            }).done(function() {
                        $("#task_link").attr({onclick: "MakeTaskDoneNot(" + id + "); return false;"});
                        $("#task_link").text("Не сделано!");
                    });
        }
    </script>
    <div class='task task-detail'>
        <div class='task-subject'>
            {{ task.subject }}
        </div>
        <div class='task-date'>
            с
            {{ task.from_date }}
            на
            {{ task.to_date }}
        </div>
        <div class='task-text'>
         {{ task.text|linebreaks }}
        </div>
        <div class="task_make_done">
            {% if state %}
                <a id="task_link" href="#" onclick="MakeTaskDoneNot({{ task.id }}); return false">Не сделано!</a>
            {% else %}
                <a id="task_link" href="#" onclick="MakeTaskDone({{ task.id }}); return false">Сделано!</a>
            {% endif %}
        </div>
        <div class='task-author'>
            {{ task.author.username }}
        </div>
        {% if task.task_type %}
            <div class='task-type'>
                {{ task.task_type }}
            </div>
        {% endif %}
    </div>
{% endblock %}
